
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>uv_signal_t — Signal handle &#8212; libuv documentation</title>
    <link rel="stylesheet" href="_static/nature.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
    <script src="_static/jquery.js"></script>
    <script src="_static/underscore.js"></script>
    <script src="_static/doctools.js"></script>
    <script src="_static/language_data.js"></script>
    <link rel="shortcut icon" href="_static/favicon.ico"/>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="uv_process_t — Process handle" href="process.html" />
    <link rel="prev" title="uv_poll_t — Poll handle" href="poll.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="process.html" title="uv_process_t — Process handle"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="poll.html" title="uv_poll_t — Poll handle"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">libuv 1.31.0 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="api.html" accesskey="U">API documentation</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href=""><code class="xref c c-type docutils literal notranslate"><span class="pre">uv_signal_t</span></code> — Signal handle</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="uv-signal-t-signal-handle">
<span id="signal"></span><h1><a class="reference internal" href="#c.uv_signal_t" title="uv_signal_t"><code class="xref c c-type docutils literal notranslate"><span class="pre">uv_signal_t</span></code></a> — Signal handle<a class="headerlink" href="#uv-signal-t-signal-handle" title="Permalink to this headline">¶</a></h1>
<p>Signal handles implement Unix style signal handling on a per-event loop bases.</p>
<div class="section" id="windows-notes">
<h2>Windows notes<a class="headerlink" href="#windows-notes" title="Permalink to this headline">¶</a></h2>
<p>Reception of some signals is emulated:</p>
<ul class="simple">
<li><p>SIGINT is normally delivered when the user presses CTRL+C. However, like
on Unix, it is not generated when terminal raw mode is enabled.</p></li>
<li><p>SIGBREAK is delivered when the user pressed CTRL + BREAK.</p></li>
<li><p>SIGHUP is generated when the user closes the console window. On SIGHUP the
program is given approximately 10 seconds to perform cleanup. After that
Windows will unconditionally terminate it.</p></li>
<li><p>Watchers for other signals can be successfully created, but these signals
are never received. These signals are: <cite>SIGILL</cite>, <cite>SIGABRT</cite>, <cite>SIGFPE</cite>, <cite>SIGSEGV</cite>,
<cite>SIGTERM</cite> and <cite>SIGKILL.</cite></p></li>
<li><p>Calls to raise() or abort() to programmatically raise a signal are
not detected by libuv; these will not trigger a signal watcher.</p></li>
</ul>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 1.15.0: </span>SIGWINCH support on Windows was improved.</p>
</div>
</div>
<div class="section" id="unix-notes">
<h2>Unix notes<a class="headerlink" href="#unix-notes" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li><p>SIGKILL and SIGSTOP are impossible to catch.</p></li>
<li><p>Handling SIGBUS, SIGFPE, SIGILL or SIGSEGV via libuv results into undefined behavior.</p></li>
<li><p>SIGABRT will not be caught by libuv if generated by <cite>abort()</cite>, e.g. through <cite>assert()</cite>.</p></li>
<li><p>On Linux SIGRT0 and SIGRT1 (signals 32 and 33) are used by the NPTL pthreads library to
manage threads. Installing watchers for those signals will lead to unpredictable behavior
and is strongly discouraged. Future versions of libuv may simply reject them.</p></li>
</ul>
</div>
<div class="section" id="data-types">
<h2>Data types<a class="headerlink" href="#data-types" title="Permalink to this headline">¶</a></h2>
<dl class="c type">
<dt id="c.uv_signal_t">
<em class="property">type </em><code class="sig-name descname">uv_signal_t</code><a class="headerlink" href="#c.uv_signal_t" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Signal handle type.</p>
</dd></dl>

<dl class="c type">
<dt id="c.uv_signal_cb">
<em class="property">typedef </em>void (*<code class="sig-name descname">uv_signal_cb</code>)<span class="sig-paren">(</span><a class="reference internal" href="#c.uv_signal_t" title="uv_signal_t">uv_signal_t</a> *handle, int signum<span class="sig-paren">)</span><a class="headerlink" href="#c.uv_signal_cb" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Type definition for callback passed to <a class="reference internal" href="#c.uv_signal_start" title="uv_signal_start"><code class="xref c c-func docutils literal notranslate"><span class="pre">uv_signal_start()</span></code></a>.</p>
</dd></dl>

<div class="section" id="public-members">
<h3>Public members<a class="headerlink" href="#public-members" title="Permalink to this headline">¶</a></h3>
<dl class="c member">
<dt id="c.uv_signal_t.signum">
int <code class="sig-prename descclassname"><a class="reference internal" href="#c.uv_signal_t" title="uv_signal_t">uv_signal_t</a><code class="sig-prename descclassname">.</code></code><code class="sig-name descname">signum</code><a class="headerlink" href="#c.uv_signal_t.signum" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Signal being monitored by this handle. Readonly.</p>
</dd></dl>

<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p>The <a class="reference internal" href="handle.html#c.uv_handle_t" title="uv_handle_t"><code class="xref c c-type docutils literal notranslate"><span class="pre">uv_handle_t</span></code></a> members also apply.</p>
</div>
</div>
</div>
<div class="section" id="api">
<h2>API<a class="headerlink" href="#api" title="Permalink to this headline">¶</a></h2>
<dl class="c function">
<dt id="c.uv_signal_init">
int <code class="sig-name descname">uv_signal_init</code><span class="sig-paren">(</span><a class="reference internal" href="loop.html#c.uv_loop_t" title="uv_loop_t">uv_loop_t</a> *<em>loop</em>, <a class="reference internal" href="#c.uv_signal_t" title="uv_signal_t">uv_signal_t</a> *<em>signal</em><span class="sig-paren">)</span><a class="headerlink" href="#c.uv_signal_init" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Initialize the handle.</p>
</dd></dl>

<dl class="c function">
<dt id="c.uv_signal_start">
int <code class="sig-name descname">uv_signal_start</code><span class="sig-paren">(</span><a class="reference internal" href="#c.uv_signal_t" title="uv_signal_t">uv_signal_t</a> *<em>signal</em>, <a class="reference internal" href="#c.uv_signal_cb" title="uv_signal_cb">uv_signal_cb</a> <em>cb</em>, int <em>signum</em><span class="sig-paren">)</span><a class="headerlink" href="#c.uv_signal_start" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Start the handle with the given callback, watching for the given signal.</p>
</dd></dl>

<dl class="c function">
<dt id="c.uv_signal_start_oneshot">
int <code class="sig-name descname">uv_signal_start_oneshot</code><span class="sig-paren">(</span><a class="reference internal" href="#c.uv_signal_t" title="uv_signal_t">uv_signal_t</a> *<em>signal</em>, <a class="reference internal" href="#c.uv_signal_cb" title="uv_signal_cb">uv_signal_cb</a> <em>cb</em>, int <em>signum</em><span class="sig-paren">)</span><a class="headerlink" href="#c.uv_signal_start_oneshot" title="Permalink to this definition">¶</a><br /></dt>
<dd><div class="versionadded">
<p><span class="versionmodified added">New in version 1.12.0.</span></p>
</div>
<p>Same functionality as <a class="reference internal" href="#c.uv_signal_start" title="uv_signal_start"><code class="xref c c-func docutils literal notranslate"><span class="pre">uv_signal_start()</span></code></a> but the signal handler is reset the moment
the signal is received.</p>
</dd></dl>

<dl class="c function">
<dt id="c.uv_signal_stop">
int <code class="sig-name descname">uv_signal_stop</code><span class="sig-paren">(</span><a class="reference internal" href="#c.uv_signal_t" title="uv_signal_t">uv_signal_t</a> *<em>signal</em><span class="sig-paren">)</span><a class="headerlink" href="#c.uv_signal_stop" title="Permalink to this definition">¶</a><br /></dt>
<dd><p>Stop the handle, the callback will no longer be called.</p>
</dd></dl>

<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p>The <a class="reference internal" href="handle.html#c.uv_handle_t" title="uv_handle_t"><code class="xref c c-type docutils literal notranslate"><span class="pre">uv_handle_t</span></code></a> API functions also apply.</p>
</div>
</div>
</div>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="index.html">
              <img class="logo" src="_static/logo.png" alt="Logo"/>
            </a></p>
  <h3><a href="index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#"><code class="xref c c-type docutils literal notranslate"><span class="pre">uv_signal_t</span></code> — Signal handle</a><ul>
<li><a class="reference internal" href="#windows-notes">Windows notes</a></li>
<li><a class="reference internal" href="#unix-notes">Unix notes</a></li>
<li><a class="reference internal" href="#data-types">Data types</a><ul>
<li><a class="reference internal" href="#public-members">Public members</a></li>
</ul>
</li>
<li><a class="reference internal" href="#api">API</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="poll.html"
                        title="previous chapter"><code class="xref c c-type docutils literal notranslate"><span class="pre">uv_poll_t</span></code> — Poll handle</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="process.html"
                        title="next chapter"><code class="xref c c-type docutils literal notranslate"><span class="pre">uv_process_t</span></code> — Process handle</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="_sources/signal.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" />
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="process.html" title="uv_process_t — Process handle"
             >next</a> |</li>
        <li class="right" >
          <a href="poll.html" title="uv_poll_t — Poll handle"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">libuv 1.31.0 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="api.html" >API documentation</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href=""><code class="xref c c-type docutils literal notranslate"><span class="pre">uv_signal_t</span></code> — Signal handle</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2014-present, libuv contributors.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
    </div>
  </body>
</html>